package com.xr.oa.supply;

import com.bstek.dorado.common.*;
import com.bstek.dorado.data.*;
import com.bstek.dorado.data.db.DBStatement;
import com.bstek.dorado.view.*;
import com.bstek.dorado.view.data.*;
import com.bstek.dorado.view.control.*;

/**
 * gettingViewModel
 */
public class gettingViewModel extends DefaultViewModel {
	 public void getting_get(ParameterSet parameters, ParameterSet outParameters)
	  throws Exception {
		  Dataset dsApply= getDataset("datasetApply"); 
		  DBStatement dbs = new DBStatement();
		  dbs.setSql("update oa_supply_apply set status=2,IF_GIVEBACK=0,FINAL_TAKE_NUM='"+dsApply.getString("FINAL_TAKE_NUM")+"' where OA_SUPPLY_APPLY_ID="+dsApply.getString("OA_SUPPLY_APPLY_ID"));
		  dbs.execute();
		  int d=dsApply.getInt("TAKE_NUM")-dsApply.getInt("FINAL_TAKE_NUM");
		  dbs.setSql("update oa_supply set SUPPLY_NUM=SUPPLY_NUM+"+d+" where OA_SUPPLY_ID="+dsApply.getString("OA_SUPPLY_ID"));
		  dbs.execute();
		  dbs.close();
	  }
	  public void getting_reject(ParameterSet parameters, ParameterSet outParameters)
	  throws Exception {
		  Dataset dsApply= getDataset("datasetApply"); 
		  DBStatement dbs = new DBStatement();
		  dbs.setSql("update oa_supply_apply set status=4,FINAL_TAKE_NUM=0 where OA_SUPPLY_APPLY_ID="+dsApply.getString("OA_SUPPLY_APPLY_ID"));
		  dbs.execute();
		  dbs.setSql("update oa_supply set supply_num=supply_num+"+dsApply.getString("TAKE_NUM")+"  where OA_SUPPLY_ID="+dsApply.getString("OA_SUPPLY_ID"));
		  dbs.execute();
		  dbs.close();
	  }
	  public void getting_giveback(ParameterSet parameters, ParameterSet outParameters)
	  throws Exception {
		  Dataset dsApply= getDataset("datasetApply"); 
		  DBStatement dbs = new DBStatement();
		  dbs.setSql("update oa_supply_apply set if_giveback=1 where status=2 and OA_SUPPLY_APPLY_ID="+dsApply.getString("OA_SUPPLY_APPLY_ID"));
		  dbs.execute();
		  dbs.close();
	  }	
}
